var fs = require('fs/promises');
// console.log(fs);


var { readFile, writeFile, unlink, mkdir, readdir, rmdir, existsSync, rename, stat } = fs;

/* var p = writeFile("./data/1.txt", "今天又是充满七万的一天", {
    encodeing: "utf-8",
    flag: "w"
})
console.log(p);

p.then(() => {
    console.log("写入成功");
}).catch(err => {
    console.log("写入失败", err);
}) */

// 异步=>Promises
// writeFile("./data/1.txt", "今天又是充满七万的一天", {
//     encodeing: "utf-8",
//     flag: "a"
// }).then(() => {
//     console.log("写入成功");
// }).catch(err => {
//     console.log("写入失败", err);
// })

(async function () {
    // await writeFile("./data/1.txt", "今天又是充满七万的一天", {
    //     encodeing: "utf-8",
    //     flag: "a"
    // })
    // console.log("写入成功");

    await rename("./data/1.txt", "./data/2.txt");
    console.log("修改成功");

})();





